package com.ethink.platform.controller.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ethink.framework.common.web.context.SPRequestContextHolder;
import com.ethink.system.api.request.SystemUserListRequest;
import com.ethink.system.api.response.SystemUserDetailResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.system.api.SystemUserFacade;
import com.ethink.system.api.info.SystemUserInfo;
import com.ethink.system.api.request.SystemUserAddRequest;
import com.ethink.system.api.request.SystemUserQueryRequest;
import com.ethink.system.api.request.SystemUserUpdateRequest;

/**
 * 系统用户表 Controller
 *
 * @author default
 * @date 2022-09-26
 */
@Tag(name = "SystemUserController", description = "系统用户表 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/system-service")
public class SystemUserController extends BaseController {

    @Autowired
    private SystemUserFacade systemUserFacade;

    @Operation(summary = "分页查询")
    @GetMapping("/systemUser/query")
    public CommonResponse<List<SystemUserInfo>> querySystemUser(SystemUserQueryRequest request) {
        return succeedWithPage(systemUserFacade.querySystemUser(request));
    }

    @Operation(summary = "详情查询")
    @GetMapping("/systemUser/get/{systemUserId}")
    public CommonResponse<SystemUserDetailResponse> getSystemUserById(@PathVariable("systemUserId") Long systemUserId) {
        return succeedWith(systemUserFacade.getSystemUserById(systemUserId));
    }

    @Operation(summary = "查询所有")
    @GetMapping("/systemUser/list")
    public CommonResponse<List<SystemUserInfo>> listSystemUser(SystemUserListRequest request) {
        return succeedWith(systemUserFacade.listSystemUser(request));
    }

    @Operation(summary = "新增")
    @PostMapping("/systemUser/add")
    public CommonResponse addSystemUser(@RequestBody SystemUserAddRequest request) {
        systemUserFacade.addSystemUser(request);
        return succeed();
    }

    @Operation(summary = "更新")
    @PostMapping("/systemUser/update")
    public CommonResponse updateSystemUser(@RequestBody SystemUserUpdateRequest request) {
        systemUserFacade.updateSystemUser(request);
        return succeed();
    }

    @Operation(summary = "删除")
    @PostMapping("/systemUser/delete/{systemUserId}")
    public CommonResponse deleteSystemUser(@PathVariable("systemUserId") Long systemUserId) {
        systemUserFacade.deleteSystemUser(systemUserId);
        return succeed();
    }

}